'''
Created on June 21, 2011

@author: yc30rr1
'''
from library.testresults.AbstractReporter import AbstractReporter
from library.AutoLoad import AutoLoad
import os, datetime
class Excel(AbstractReporter):
    '''
    classdocs
    
    '''
    _headers=('TEST CASE ID','RESULT','TC NOTES')
    rowVal=0
    tcResults=[]

    def __init__(self, setupInfo):
        self.resultLocation=setupInfo[0][1]
        self.creatExcelForResult()
        super(self.__class__, self).__init__()
   
    def updateResult(self, instance):
        del self.tcResults[:]
        self.tcResults.append(instance.tcid)
        self.tcResults.append(instance.tcResult)
        self.tcResults.append(instance.tcNotes)
        self.Obj.addRow(self.resultLocation, "Result",self.tcResults,self.rowVal)
        self.rowVal=self.rowVal+1
        
    def creatExcelForResult(self):
        timeStamp = datetime.datetime.now()
        timeStamp1 = str(timeStamp)
        timeStamp2 = timeStamp1.replace(':','_').strip()
        self.resultLocation=self.resultLocation+os.sep+'Results'+timeStamp2+'.xls'
        self.Obj=AutoLoad.ClassAsObject('library.helpers.ExcelReporting')
        self.Obj.createExcelFile(self.resultLocation,'Result',self._headers,self.rowVal)
        self.rowVal=self.rowVal+2
        


        
